//
//  DateKLineData.h
//  Chart
//
//  Created by CaoJun on 13-9-5.
//
//

#ifndef __Chart__DateKLineData__
#define __Chart__DateKLineData__

#include "KLineData.h"
#include "TimeKLineData.h"

#include <string>
#include <vector>

namespace ytx {
    
    class DateKLineData;
    
    class KLineDataHandlerOfDayKLineData : public Observer<KLineData>
    {
    private:
        DateKLineData & kLineData;
    public:
        virtual void handle(KLineData * dayK, std::string eventName, void * data);
        KLineDataHandlerOfDayKLineData(DateKLineData & kLineData);
    };
    
    class DateKLineData : public KLineData{
        
    public:
        DateKLineData(std::string id, std::string currentDate, LineType::LineType quotationType, std::string marketType, int toFix, std::string name, std::string nickName, bool hasVolume, int limit, int threshold, int buffer, YTXTime tradedate, TimeKLineData * dayK);
        TimeKLineData * dayK;
        
        virtual void listenOn();
        
        virtual void listenOff();
        
        virtual bool checkNeedGetNewK();
        
        virtual void getCloseNewK();
        
        virtual bool isInLatestNewK(YTXTime tradedate1, YTXTime tradedate2);
        
        virtual void intervalRequestDataInterface();
        
        virtual void getK();
        virtual void calculateTodayKLine();

    protected:
        KLineDataHandlerOfDayKLineData dataHandler;
        
        virtual unsigned int filterDataFrom(std::vector<KLineItem> & data, std::vector<std::string> & dates);
        
        virtual unsigned int filterDataTo(std::vector<KLineItem> & data, std::vector<std::string> & dates);
        
    };
}


#endif /* defined(__Chart__DateKLineData__) */
